package cn.ali.controller;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

public class BeanNameUrlHandlerMapping_demo implements Controller {


    /**
     * 使用这种方式配置的controller [ <bean name="/controllerImpl" class="cn.ali.controller.BeanNameUrlHandlerMapping_demo"></bean>]
     * 会使用 BeanNameUrlHandlerMapping  --> SimpleControllerHandlerAdapter
     *
     * 而使用@controller注解的类
     * 会使用 RequestMappingHandlerMapping  --> RequestMappingHandlerAdapter
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        System.out.println("这是实现Controller接口的类ControllerImpl被调用.......");
        Map parameterMap = request.getParameterMap();
        System.out.println("请求参数:" + parameterMap);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("users");
        return modelAndView;
    }
}
